package com.phuonghoang.vnexpress;

import com.phuonhoang.utils.Variables;

import android.app.Activity;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class NewAcitivty extends Activity {
private WebView webView;
private String link;
private ProgressDialog dialog;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.new_activity);
		Bundle bundle = getIntent().getExtras();
		setTitle(R.string.app_name);
		link = bundle.getString(Variables.LINK);
		webView = (WebView)findViewById(R.id.wvNews);
		//config all web
		webView.getSettings().setSupportMultipleWindows(true);
		webView.setInitialScale(1);
		webView.getSettings().setLoadWithOverviewMode(true);
		webView.getSettings().setUseWideViewPort(true);
		webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
		webView.setScrollbarFadingEnabled(false);
		webView.setWebViewClient(new WebViewClient());
		
		webView.loadUrl(link);
		dialog = ProgressDialog.show(NewAcitivty.this, "", "Loading..");
		new NewsTask().execute();
	}
class NewsTask extends AsyncTask<Void, Void, Void>{

	@Override
	protected Void doInBackground(Void... params) {
		Toast.makeText(getApplicationContext(), ""+link, Toast.LENGTH_SHORT).show();
		//webView.loadUrl(link);
		return null;
	}
	
}
class WebClient extends WebViewClient{

	@Override
	public void onPageFinished(WebView view, String url) {
		if (dialog != null) {
			dialog.dismiss(); 
		}
		super.onPageFinished(view, url);
	}
	
}
}
